{include file='header'/}
<body>
<div class="weadmin-body">
    <h1>备注：要使用Ueditor编辑器里的上传插件，需禁用tp的调试app_trace</h1>
    <hr>

    <form class="layui-form" action="javascript:;" onsubmit="return dosub(this)">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>使用 Layui 自带，常规上传</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">上传图片1</label>
            <div class="layui-input-inline" style="width: 40%">
                <input type="text" name="demo1"  value=""  onmouseover="hui_img_preview('demo1',this.value)" onmouseout="layer.closeAll();" id="demo1" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-input-inline" style="width: 120px">
                <button type="button" class="layui-btn" id="test1" ><i class="layui-icon">&#xe67c;</i>上传图片</button>
            </div>
            <div class="layui-input-inline" style="width: 120px">
                <button type="button" class="layui-btn layui-btn-normal" onclick="WeAdminShow('选择图片','{:url('general.attachment/select',[\'id\'=>\'demo1\'])}','800')"><i class="layui-icon">&#xe605;</i>选择图片</button>
            </div>
            <div class="layui-input-inline" style="width: 120px">
                <button type="button" class="layui-btn layui-btn-fense" id="pic_cropper" onclick="hui_img_cropper('demo1','{:url(\'upload/img_cropper\')}')"><i class="layui-icon layui-icon-picture"></i>裁剪图片</button>
            </div>
        </div>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>使用 Ueditor 自写方法上传</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="we-red">*</span>内容
            </label>
            <div class="layui-input-block">
                {php}echo lib\Form::editor('content', '', 'width:100%;height:400px', true);{/php}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <input type="checkbox" name="auto_thum" value="1" title="提取内容第一张图片为缩略图" lay-skin="primary" checked>
            </div>
        </div>
    </form>
</div>
{include file='footer'/}
<!-- 实例化编辑器 -->
<script type="text/javascript">

    layui.use(['form','upload'], function() {
        var form = layui.form,
            upload = layui.upload;
        form.render();

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: "{:url('upload/index')}"
            ,field:"Filedata"
            ,done: function(res){
                console.log(res.src)
                if(res.status==1){
                    $("#demo1").val(res.src);
                }
            }

        })
    });
</script>
</body>
</html>